	//동호회정보
	function clsClubJoin_Info(){
		this.listData = null;
		this._HTMLDom = null;
		this.errMsg = null;
		this._ERRMSG = {
			"_NOVALUE": "질문답변을 입력하여 주십시요."	
		}
		this._init();
	}
	
	clsClubJoin_Info.prototype = {
		_init: function(){
			var $layer = $("section#club_join>section form");			
			this._HTMLDom = {
				"$layer": $layer
			}
			$layer.hide();			
		}
		, setData: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"]; 
			
			$layer.find("div.club_join_txt:eq(0) mark").html(this.listData["동호회명"]);
			
			if(this.listData["가입유형"] == "N"){
				$layer.find("div.club_join_txt:eq(1)").hide();			
				$layer.find("ul.club_join_form").hide();					
			}else {
				$layer.find("p.align_c").hide();	
			}
			
			$layer.show();
		}
		, getValue: function(){
			return this._HTMLDom["$layer"].find("textarea").val();	
		}
		, $getBtnConfirm: function(){
			return this._HTMLDom["$layer"].find("div.bt_club div div a:eq(0)");	
		}
		, $getBtnCancel: function(){
			return this._HTMLDom["$layer"].find("div.bt_club div div a:eq(1)");	
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, isValid: function(){
			
			if(this.listData["가입유형"] == "N"){
				return true;
			}else if(this.getValue().trim().length == 0){
				this.errMsg = this._ERRMSG["_NOVALUE"];
				return false;	
			}	
			
			return true;
		}
		, getError: function(){
			return this.errMsg;	
		}
	}	
	
	//데이터연동		
	function clsComm_ClubJoin(){
		this._init();
	}	
	clsComm_ClubJoin.prototype = {
		_init: function(){

		}
//------------------------ 동호회가입------------------------//				
		, clubJoinSubmit: function(arg){
			var thisClass =  this;
			var szClubSeq = arg["동호회키"];
			var szClubQuestion = arg["질문답변"];
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename","registMember");   
        					
        	objJson.putParameter("clubSeq", szClubSeq);
        	objJson.putParameter("joinment", szClubQuestion);
        	
			cm.requestGet(objJson.getJsonString(), function(ret){
			
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지":  _util.getResultMsg(ret,["신청"])
				}				
				$(thisClass).trigger("evtFinishClubJoinSubmit",[resData]);
			}, function($err) {
				alert($err);
			});	
		}
//------------------------ 동호회가입------------------------//		
	}
	
	//컨트롤파일
	function ClubJoin(){				
		this.objComm = null;
		this.club_seq = null;	
		this.club_info = null;		
		
		this.objClubJoin_Info = null;
	};
	
	ClubJoin.prototype = {
	    onPageShow : function() {	    
	    	$("a").attr("href", "").attr("data-rel", "");      
	    	this._init();	    		    	
	    }
	    , _beforeStart: function(){
	    	var 	thisClass = this;
	    	
	    	this._permitStart = {
				"동호회정보": false	
			}
			
	  		// 서버 메시지맵
			$.ajax({
				url: "../js/src/club/club_inc.js"
				, type: "get"
				, dataType: "script"
				, async: false
				, success: function(ret, sta){
					//alert("success!!");					
				}
				, error:function(e){
					alert("error=" + e);
				}	
			});
			
			_cb.getClubInfoData({
				"콜백": function(ret, l){
					thisClass._permitStart["동호회정보"] = true;	
				}
			});
			
			_util.executeThread(function(){
				for(key in thisClass._permitStart){		
					if(!thisClass._permitStart[key]) return false;
				}
				return (true);
			}, function(){			
				thisClass._start();
			});
	    }
	    , _init: function(){	    	    	
	   		
	    	this.objComm = new clsComm_ClubJoin();
			this.objClubJoin_Info = new clsClubJoin_Info();
			
	      this.getParam();
	      
	      this._beforeStart();
	    	
	    	this._bind();	 
	      	this._eventFinish();     	
	    }
	    , _start: function(){	    	
	    	//동호회기본정보
	    	this.club_info = _cb.getClubInfo();
	    	
	    	this._role();
	    	
	    	//동호회정보
	    	this.spinStart();
			this.objClubJoin_Info.setData(this.club_info.listData);
			
			this.spinEnd();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	// 동호회가입 완료이벤트
			$(this.objComm).bind("evtFinishClubJoinSubmit", function(event, resData){
				thisClass.spinEnd();
				alert(resData["메세지"]);
				if(resData["응답코드"]){
					_gf.CLUB_DATA = {
						"동호회키": thisClass.club_seq	
					}
			 		$.mobile.changePage("self_club.html","slide",true);	
				}
			});
	    }
		 , _bind: function(){
		 	var thisClass = this;		 	
			
			//확인
			this.objClubJoin_Info.$getBtnConfirm().click(function(event){
				event.preventDefault();
				
				if(!thisClass.objClubJoin_Info.isValid()){
					alert(thisClass.objClubJoin_Info.getError());
					return;
				}
				
		 		var submitData = {
		 			"동호회키": thisClass.club_seq	
		 			, "질문답변": thisClass.objClubJoin_Info.getValue()
		 		}
		 		
		 		thisClass.objComm.clubJoinSubmit(submitData);
			});
			
			//취소
			this.objClubJoin_Info.$getBtnCancel().click(function(event){
				event.preventDefault();
		 		_gf.CLUB_DATA = {
					"동호회키": thisClass.club_seq	
				}
		 		$.mobile.changePage("self_club.html","slide",true);	
			});	 	
			
		 	//메뉴
		 	$("section#club_join nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#club_join nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//이전
		 	$("section#club_join header div.top_title_G div.top_left a.btn2").click(function(event){
		 		event.preventDefault();
		 		_gf.CLUB_DATA = {
					"동호회키": thisClass.club_seq	
				}
		 		$.mobile.changePage("self_club.html","slide",true);	
		 	});
		 }
		 , getParam: function(){
	    	this.club_seq = _gf.CLUB_DATA["동호회키"];
	    }
	    , _role: function(){	    
	    	if(!_util.getLogin()){
	    		this.goLogin();
	    	}else if(this.club_info.isMember()){	    		
	    		alert("이미 동호회에 가입되어 있습니다.");
	    		_gf.CLUB_DATA = {
					"동호회키": this.club_seq	
				}
		 		$.mobile.changePage("self_club.html","slide",true);	
	    	}
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, goLogin: function(_url){
			_gf.LOGIN_DATA.loginAfterUrl = "../club/club_join.html";
			if(_url) _gf.LOGIN_DATA.loginAfterUrl = _url;
			$.mobile.changePage("../member/login.html","slide",true); 
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}	